import Vue from 'vue'
import App from './App'
import store from './store/index.js'

Vue.prototype.$store = store

Vue.config.productionTip = false

// 引入全局组件
// import divider from './components/common/divider.vue';
// Vue.component('divider', divider);
// import noThing from './components/common/no-thing.vue';
// Vue.component('no-thing',noThing);
// import myInput from './@/pages/components/my-input.vue';
// Vue.component('my-input',myInput);

//引入配置文件
import configApi from '@/common/config.js';
Vue.prototype.config = configApi;
// 挂在助手函数
import utilJs from '@/common/util.js';
Vue.prototype.utilJs = utilJs;

// 引入请求库
import hRequire from '@/common/require.js';
Vue.prototype.hRequire = hRequire;

import share from '@/common/share.js'
Vue.mixin(share)

import uView from "uview-ui";
Vue.use(uView);

// 权限验证操作
Vue.prototype.checkAuth = (callback)=>{
	// 权限验证
	if(store.state.loginStatus){
		uni.showToast({
			title:'请先登录',
			icon: 'none'
		});
		return uni.switchTab({
							url: '/pages/my/my',
						})
	}
	callback()
}

// 权限验证跳转
Vue.prototype.navigate = (options)=>{
	// 权限验证
	if(store.state.loginStatus){
		uni.showToast({
			title:'请先登录',
			icon: 'none'
		});
		return uni.switchTab({
							url: '/pages/my/my',
						})
	}
	uni.navigateTo(options);
}

App.mpType = 'app'

const app = new Vue({
	store,
    ...App
})
// http拦截器，将此部分放在new Vue()和app.$mount()之间，才能App.vue中正常使用
import httpInterceptor from '@/common/http.interceptor.js'
Vue.use(httpInterceptor, app)

// http接口API集中管理引入部分
import httpApi from '@/common/http.api.js'
Vue.use(httpApi, app)

app.$mount()
